#ifndef GAMEENGINE_GEOMETRY_CORE_INTERVAL_H
#define GAMEENGINE_GEOMETRY_CORE_INTERVAL_H

#include <GameEngine/Geometry/geometry_settings.h>


#ifdef GAMEENGINE_NAMESPACES
namespace GameEngine {
#endif

//=================================================================================


//! Implementation of a interval of values
/*!
 *  A interval defines an interval of values comprised between
 *  optional minimum and maximum values. If either no minimum
 *  (respectively maximum) value is set, the minimum
 *  (respectively maximum) value is implicitly set to -infinity
 *  (respectively +infinity).
 *
 *  The minimum and maximum values can either be included in
 *  the interval or excluded from the interval.
 *
 @todo Setup unit tests
 */
template <class T>
class Interval {

public:
	Interval();
	Interval(const T& min_defined, const T& max_defined);
	Interval(const Interval& rhs);
	virtual ~Interval();
	Interval& operator=(const Interval& rhs);

	bool operator==(const Interval& rhs) const;
	bool operator!=(const Interval& rhs) const;

	T get_min(bool* use_min = nil) const;
	T get_max(bool* use_max = nil) const;

	void set_min(const T& min);
	void set_max(const T& max);
	void remove_min();
	void remove_max();

	bool min_included() const;
	bool max_included() const;
	bool& min_included();
	bool& max_included();

	bool empty_interval() const;
	bool full_interval() const;
	bool finite_interval() const;

	bool inside(const T& value) const;
	bool intersect(const Interval& rhs) const;
	bool included(const Interval& rhs) const;

	Interval intersection(const Interval& rhs) const;

	T length() const;

private:
	T min_;
	bool min_defined_;
	bool min_included_;
	T max_;
	bool max_defined_;
	bool max_included_;
};

#ifdef GAMEENGINE_NAMESPACES
} // namespace GameEngine
#endif

//=================================================================================

#include <GameEngine/Geometry/Core/interval.hpp>

#endif